var https = require('https')
var express = require('express')
var app = express();
var nunjucks = require('nunjucks')
    // var querystring = require('querystring');
var zlib = require('zlib');

var rootRoute = require('./routes/rootRoute.js');
var rankApi = require('./routes/rankApi');
var commentApi = require('./routes/commentApi.js')

app.set('views', './views')
app.use(express.static('public'))

nunjucks.configure('views', {
    autoescape: true,
    express: app,
    noCache: process.env.NODE_ENV !== 'production'
})


app.use('/', rootRoute);
app.use('/api/rankApi', rankApi);
app.use('/api/commentApi', commentApi);


//服务
var server = app.listen(80, '127.0.0.1', function() {
    var host = server.address().address;
    var port = server.address().port;
    console.log('running at http://' + host + ':' + port);
})